<?php

namespace app\home\controller;

use app\common\service\UserService;
use think\Controller;

class Login extends Controller
{
    /**
     * 显示资源列表
     */
    public function index()
    {
        return $this->fetch();
    }

    public function login()
    {
        $server   = new UserService();
        $phone    = input('phone');
        $password = input('password');
        return $server->login($phone, $password);
    }

    public function reg()
    {
        return $this->fetch();
    }

    public function sign()
    {
//        注册
        $server = new UserService();
        $data   = input();
        return $server->reg($data);
    }

    public function logout()
    {
        session('uid', null);
        session('uid', null);
        return json(['code' => 0, 'msg' => '退出成功']);
    }

    public function forget()
    {
        return $this->fetch();
    }
}
